package com.cloud.system.api.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cloud.system.api.bean.SysConfigForm;
import com.cloud.system.api.service.SysConfigService;
import com.cloud.system.common.exception.BizException;
import com.cloud.system.common.result.Quokka;

@RestController
@RequestMapping("system/api/config")
public class SysConfigController {

	@Autowired
	private SysConfigService sysConfigService;

	@RequestMapping("/list")
	public Quokka list() {
		return new Quokka(true, sysConfigService.list());
	}

	@RequestMapping("/load")
	public Quokka load(String configKey) {
		return new Quokka(true, sysConfigService.load(configKey));
	}

	@RequestMapping("/saveupdate")
	public Quokka saveUpdate(@RequestBody(required = true) SysConfigForm form) throws BizException {
		return new Quokka(true, sysConfigService.saveUpdateConfig(form));
	}

	@RequestMapping("/delete")
	public Quokka delete(String configKey) {
		return new Quokka(true, sysConfigService.delete(configKey));
	}

}
